﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Command
{
    public class DBHelper
    {
        private static string ConString = "Data Source=.;Initial Catalog=BookStores;Integrated Security=True";

        public static SqlDataReader Getdata(string sql)
        {
            SqlConnection con = new SqlConnection(ConString);
            con.Open();
            SqlCommand com = new SqlCommand(sql, con);
            return com.ExecuteReader(CommandBehavior.CloseConnection);
        }
        public static int Adddata(string sql)
        {
            SqlConnection con = new SqlConnection(ConString);
            con.Open();
            SqlCommand com = new SqlCommand(sql, con);
            int a = com.ExecuteNonQuery();
            con.Close();
            return a;
        }
    }
}
